! function($) {
	return $ ? ($.Unslider = function(t, n) {
		var e = this;
		return e._ = "unslider", e.defaults = {
				autoplay: !1,
				delay: 3e3,
				speed: 750,
				easing: "swing",
				keys: {
					prev: 37,
					next: 39
				},
				nav: !0,
				arrows: {
					prev: '<a class="' + e._ + '-arrow prev"></a>',
					next: '<a class="' + e._ + '-arrow next"></a>'
				},
				animation: "horizontal",
				selectors: {
					container: "ul:first",
					slides: "li"
				},
				animateHeight: !1,
				activeClass: e._ + "-active",
				swipe: !0,
				swipeThreshold: .2
			}, e.$context = t, e.options = {}, e.$parent = null, e.$container = null, e.$slides = null, e.$nav = null, e.$arrows = [],
			e.total = 0, e.current = 0, e.prefix = e._ + "-", e.eventSuffix = "." + e.prefix + ~~(2e3 * Math.random()), e.interval =
			null, e.init = function(t) {
				return e.options = $.extend({}, e.defaults, t), e.$container = e.$context.find(e.options.selectors.container).addClass(
						e.prefix + "wrap"), e.$slides = e.$container.children(e.options.selectors.slides), e.setup(), $.each(["nav",
						"arrows", "keys", "infinite"
					], function(t, n) {
						e.options[n] && e["init" + $._ucfirst(n)]()
					}), jQuery.event.special.swipe && e.options.swipe && e.initSwipe(), e.options.autoplay && e.start(), e.calculateSlides(),
					e.$context.trigger(e._ + ".ready"), e.animate(e.options.index || e.current, "init")
			}, e.setup = function() {
				e.$context.addClass(e.prefix + e.options.animation).wrap('<div class="' + e._ + '" />'), e.$parent = e.$context.parent(
					"." + e._);
				var t = e.$context.css("position");
				"static" === t && e.$context.css("position", "relative"), e.$context.css("overflow", "hidden")
			}, e.calculateSlides = function() {
				if (e.total = e.$slides.length, "fade" !== e.options.animation) {
					var t = "width";
					"vertical" === e.options.animation && (t = "height"), e.$container.css(t, 100 * e.total + "%").addClass(e.prefix +
						"carousel"), e.$slides.css(t, 100 / e.total + "%")
				}
			}, e.start = function() {
				return e.interval = setTimeout(function() {
					e.next()
				}, e.options.delay), e
			}, e.stop = function() {
				return clearTimeout(e.interval), e
			}, e.initNav = function() {
				var t = $('<div class="' + e.prefix + 'nav"><ol /></div>');
				e.$slides.each(function(n) {
					var i = this.getAttribute("data-nav") || n + 1;
					$.isFunction(e.options.nav) && (i = e.options.nav.call(e.$slides.eq(n), n, i)), t.children("ol").append(
						'<li data-slide="' + n + '" class="unslider unslider-nav-li">' + "</li>")
				}), e.$nav = t.insertAfter(e.$context), e.$nav.find("li").on("click" + e.eventSuffix, function() {
					var t = $(this).addClass(e.options.activeClass);
					t.siblings().removeClass(e.options.activeClass), e.animate(t.attr("data-slide"))
				})
			}, e.initArrows = function() {
				e.options.arrows === !0 && (e.options.arrows = e.defaults.arrows), $.each(e.options.arrows, function(t, n) {
					e.$arrows.push($(n).insertAfter(e.$context).on("click" + e.eventSuffix, e[t]))
				})
			}, e.initKeys = function() {
				e.options.keys === !0 && (e.options.keys = e.defaults.keys), $(document).on("keyup" + e.eventSuffix, function(t) {
					$.each(e.options.keys, function(n, i) {
						t.which === i && $.isFunction(e[n]) && e[n].call(e)
					})
				})
			}, e.initSwipe = function() {
				var t = e.$slides.width();
				"fade" !== e.options.animation && e.$container.on({
					movestart: function(t) {
						return t.distX > t.distY && t.distX < -t.distY || t.distX < t.distY && t.distX > -t.distY ? !!t.preventDefault() :
							void e.$container.css("position", "relative")
					},
					move: function(n) {
						e.$container.css("left", -(100 * e.current) + 100 * n.distX / t + "%")
					},
					moveend: function(n) {
						Math.abs(n.distX) / t > e.options.swipeThreshold ? e[n.distX < 0 ? "next" : "prev"]() : e.$container.animate({
							left: -(100 * e.current) + "%"
						}, e.options.speed / 2)
					}
				})
			}, e.initInfinite = function() {
				var t = ["first", "last"];
				$.each(t, function(n, i) {
					e.$slides.push.apply(e.$slides, e.$slides.filter(':not(".' + e._ + '-clone")')[i]().clone().addClass(e._ +
						"-clone")["insert" + (0 === n ? "After" : "Before")](e.$slides[t[~~!n]]()))
				})
			}, e.destroyArrows = function() {
				$.each(e.$arrows, function(t, n) {
					n.remove()
				})
			}, e.destroySwipe = function() {
				e.$container.off("movestart move moveend")
			}, e.destroyKeys = function() {
				$(document).off("keyup" + e.eventSuffix)
			}, e.setIndex = function(t) {
				return 0 > t && (t = e.total - 1), e.current = Math.min(Math.max(0, t), e.total - 1), e.options.nav && e.$nav.find(
						'[data-slide="' + e.current + '"]')._active(e.options.activeClass), e.$slides.eq(e.current)._active(e.options.activeClass),
					e
			}, e.animate = function(t, n) {
				if ("first" === t && (t = 0), "last" === t && (t = e.total), isNaN(t)) return e;
				e.options.autoplay && e.stop().start(), e.setIndex(t), e.$context.trigger(e._ + ".change", [t, e.$slides.eq(t)]);
				var i = "animate" + $._ucfirst(e.options.animation);
				return $.isFunction(e[i]) && e[i](e.current, n), e
			}, e.next = function() {
				var t = e.current + 1;
				return t >= e.total && (t = 0), e.animate(t, "next")
			}, e.prev = function() {
				return e.animate(e.current - 1, "prev")
			}, e.animateHorizontal = function(t) {
				var n = "left";
				return "rtl" === e.$context.attr("dir") && (n = "right"), e.options.infinite && e.$container.css("margin-" + n,
					"-100%"), e.slide(n, t)
			}, e.animateVertical = function(t) {
				return e.options.animateHeight = !0, e.options.infinite && e.$container.css("margin-top", -e.$slides.outerHeight()),
					e.slide("top", t)
			}, e.slide = function(t, n) {
				if (e.options.animateHeight && e._move(e.$context, {
						height: e.$slides.eq(n).outerHeight()
					}, !1), e.options.infinite) {
					var i;
					n === e.total - 1 && (i = e.total - 3, n = -1), n === e.total - 2 && (i = 0, n = e.total - 2), "number" ==
						typeof i && (e.setIndex(i), e.$context.on(e._ + ".moved", function() {
							e.current === i && e.$container.css(t, -(100 * i) + "%").off(e._ + ".moved")
						}))
				}
				var o = {};
				return o[t] = -(100 * n) + "%", e._move(e.$container, o)
			}, e.animateFade = function(t) {
				var n = e.$slides.eq(t).addClass(e.options.activeClass);
				e._move(n.siblings().removeClass(e.options.activeClass), {
					opacity: 0
				}), e._move(n, {
					opacity: 1
				}, !1)
			}, e._move = function(t, n, i, o) {
				return i !== !1 && (i = function() {
					e.$context.trigger(e._ + ".moved")
				}), t._move(n, o || e.options.speed, e.options.easing, i)
			}, e.init(n)
	}, $.fn._active = function(t) {
		return this.addClass(t).siblings().removeClass(t)
	}, $._ucfirst = function(t) {
		return (t + "").toLowerCase().replace(/^./, function(t) {
			return t.toUpperCase()
		})
	}, $.fn._move = function() {
		return this.stop(!0, !0), $.fn[$.fn.velocity ? "velocity" : "animate"].apply(this, arguments)
	}, void($.fn.unslider = function(t) {
		return this.each(function() {
			var n = $(this);
			if ("string" == typeof t && n.data("unslider")) {
				t = t.split(":");
				var e = n.data("unslider")[t[0]];
				if ($.isFunction(e)) return e.apply(n, t[1] ? t[1].split(",") : null)
			}
			return n.data("unslider", new $.Unslider(n, t))
		})
	})) : console.warn("Unslider needs jQuery")
}(window.jQuery);
//插件名字：power-slider（多功能滚动插件）
//插件作者：蔡宝坚
//作者博客：http://caibaojian.com
//插件网站：http://caibaojian.com/power-slider
//使用协议：在保留头部版权的情况下，个人和商业均可免费使用
//使用范例：http://caibajian.com/demo/power-slider
! function(a) {
	a.fn.powerSlider = function(b) {
		return this.each(function() {
			function w(a, b) {
				var c = e.height(),
					f = e.width();
				if (u.hide().eq(b).show(), v.removeClass("current").eq(b).addClass("current"), h.removeClass("current").eq(b).addClass(
						"current"), "top" == d.handle) g.filter(":not(':animated')").animate({
					top: -c * b
				}, d.speed);
				else if ("left" == d.handle) h.css("float", "left"), g.css("width", k * f).filter(":not(':animated')").animate({
					left: -f * b
				}, d.speed);
				else if ("hide" == d.handle) {
					var i = b + 1;
					h.hide().slice(b * d.sliderNum, i * d.sliderNum).show()
				} else "fadeTo" == d.handle ? (h.slice(a * d.sliderNum, (a + 1) * d.sliderNum).fadeOut(d.speed), h.slice(b * d.sliderNum,
					(b + 1) * d.sliderNum).filter(":not(':animated')").fadeIn(d.speed)) : "slideTo" == d.handle && h.css("z-index",
					"1").filter(":not(':animated')").slideUp().slice(b * d.sliderNum, (b + 1) * d.sliderNum).css("z-index", "2").slideDown(
					d.speed)
			}

			function x() {
				var a = f;
				f = (f + 1) % k, w(a, f)
			}
			for (var c = {
					handle: "top",
					prevNext: !0,
					Nav: !0,
					myTitle: !1,
					speed: 600,
					delayTime: 6e3,
					clickMode: "click",
					sliderNum: 1
				}, d = a.extend({}, c, b), e = a(this), f = 0, g = a(".sliderbox", e), h = g.find("li"), k = (a(
					".sliderbox li:eq(0)").outerWidth(), h.length, h.length / d.sliderNum), k = Math.ceil(k), l = a(" .slidernav",
					e), m = a(" .slidertext", e), n = a(" .prev", e), o = a(" .next", e), q = "", s = 0; k > s; s++) q +=
				'<li><a href="javascript:void(0);">' + (s + 1) + "</a></li>";
			if ("fadeTo" == d.handle) {
				d.sliderNum <= 1 ? h.css({
					position: "absolute",
					left: "0",
					top: "0"
				}) : h.each(function(b) {
					a(this).css({
						position: "absolute",
						left: b % d.sliderNum * h.width(),
						top: "0"
					})
				});
				var t = parseInt(d.sliderNum - 1);
				g.find("li:gt(" + t + ")").hide()
			}
			d.Nav && l.append(q), d.sliderNum > 1 && h.css("float", "none");
			var u = m.find("li"),
				v = l.find("li");
			u.eq(0).show(), v.eq(0).addClass("current"), h.eq(0).addClass("current"), v.bind(d.clickMode, function() {
				f = a(this).index();
				var b = v.index(a(".slidernav .current:eq(0)"));
				f != b && w(b, f)
			}), 1 >= k ? (n.hide(), o.hide()) : d.prevNext && (n.click(function() {
				var a = f;
				f -= 1, -1 == f && (f = k - 1), w(a, f)
			}), o.click(function() {
				x()
			}));
			var y;
			e.hover(function() {
				clearInterval(y);
			}, function() {
				y = setInterval(function() {
					x()
				}, d.delayTime)
			}).trigger("mouseleave")
		})
	}
}(jQuery);
(function(window, $) {
	$('.banner', '#index').unslider({
		autoplay: true,
		infinite: true,
		delay: 3000
	});
	$('#quips').powerSlider({
		delayTime: 3000,
		sliderNum: 2
	});
	$('#topic').powerSlider({
		delayTime: 3000,
		sliderNum: 2
	});
	$('.banner>ul>li>a.banner-href').each(function() {
		var protocol = $(this).attr('data-protocol');
		var type = $(this).attr('data-type');
		var url = $(this).attr('data-url');
		var href = '';
		if ('web' == type) {
			href = url;
		} else if ('product' == type) {
			href = '/product-' + url + '.html';
		} else if ('topic' == type) {
			if (protocol.indexOf('mwactivity') > -1) {
				href = '/activity?' + protocol.replace('mwactivity://', '');
			} else {
				href = '/post-' + url + '.html';
			}
		} else if ('cat' == type) {
			href = '/cat-' + url + '.html';
		}
		if (!app.util.isEmpty(href)) {
			$(this).attr('href', href);
		}
	});
	$('h2.product-brief').each(function() {
		$(this).text(app.util.ellipsisStr($(this).text(), 40));
	});
	$('.attitude img').on("click", function(e) {
		e.preventDefault();
		var $this = $(this);
		var gid = $this.attr("data-goods-id"),
			attitude = $this.attr("data-attitude-id");
		if (gid <= 0) {
			app.error("您没有选择任何商品信息");
			return false;
		}
		app.post("/setGoodsLikeAttitude", {
			id: gid,
			like: attitude
		}, function(rs) {
			if (1 == rs.resultCode) {
				var attitude = rs.attitudes.attitude;
				$this.attr("data-attitude-id", attitude);
				$this.attr("src", "/s/img/like_" + attitude + ".png").data("attitude", attitude);
			} else if (rs.resultCode == 12) { // not logined
				app.error('请先登录后再操作', function() {
					$.regLoginFrame('login');
				});
			} else {
				app.error(rs.resultMsg);
			}
		});
	});

})(window, jQuery);
